package com.zzh.demo.agentDemo.visitor;

import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;

/**
 * description： <br>
 * createTime: 2024/2/29 11:36 <br>
 *
 * @author zzh
 */
public class TimeStatisticsVisitor extends ClassVisitor {

    public TimeStatisticsVisitor(int api, ClassVisitor classVisitor) {
        super(Opcodes.ASM5, classVisitor);
    }

    @Override
    public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
        MethodVisitor mv = cv.visitMethod(access, name, descriptor, signature, exceptions);
        if (name.equals("<init>")) {
            return mv;
        }
        return new TimeStatisticsAdapter(api, mv, access, name, descriptor);
    }
}